package com.wangcanxuan.www.controller.Impl;

import com.wangcanxuan.www.controller.ApplyController;
import com.wangcanxuan.www.entity.dto.ResultInfo;
import com.wangcanxuan.www.entity.po.User;
import com.wangcanxuan.www.proxy.ServiceProxy;
import com.wangcanxuan.www.service.ApplyService;
import com.wangcanxuan.www.service.Impl.ApplyServiceImpl;

import java.util.List;

/**
 * 应申请controller层实现类
 *
 * @author HHLJ
 * @date 2022/04/07
 */
public class ApplyControllerImpl implements ApplyController {

    private final ApplyService applyService = ServiceProxy.getProxyInstance(ApplyServiceImpl.class);

    @Override
    public ResultInfo<String> applyTribe(User user, String tribeName) {
        ResultInfo<String> resultInfo = applyService.applyTribe(user, tribeName);
        if (resultInfo.isSuccess()) {
            resultInfo.setMessage("申请成功！");
        }
        return resultInfo;
    }

    @Override
    public ResultInfo<List<User>> selectApplyListByTribeId(String tribeId, int pageCount) {
        return applyService.selectApplyListByTribeId(tribeId, pageCount);
    }

    @Override
    public ResultInfo<Boolean> solveApply(String chooseUserName, User user, int status) {
        ResultInfo<Boolean> resultInfo = applyService.solveApply(chooseUserName, user, status);
        if (resultInfo.isSuccess()) {
            Boolean flag = resultInfo.getObj();
            if (flag) {
                resultInfo.setMessage("同意成功！");
            } else {
                resultInfo.setMessage("拒绝成功！");
            }
        }
        return resultInfo;
    }

}
